<style>
  
  .logManagement {
    padding:10px;
    min-height:600px;
  }

</style>

<template>
  
   <div class="manage-wrap">
    <div class="operation-panel">
      <Row>
        <Col span="24">
<Poptip width="400" title='搜索' placement="bottom-end" class="float-r">
            <Button type="primary" size="large" icon="ios-search">搜  索</Button>
            <div style="text-align:center" slot="content">
              <Form ref="searchForm" :model="searchForm" :label-width="80"  value=true  style="min-width:200px;padding-top:20px;border-top:1px solid #a3adba;border-bottom:1px solid #a3adba;">
                <Row>
                  <Form-item label="用户名或操作"  >
                    <Input v-model="searchForm.key" ></Input>
                  </Form-item>
                </Row>
              </Form>
              <Row >
                <Button  style="margin-left:5px;margin-top:10px;float:right;background-color: #5bc0de;color:#fff" size="small"   @click="doSearchTableList">确定</Button>
                <Button  style="float:right;margin-top:10px;" size="small" @click="resetSearch" >重置</Button>
              </Row>
            </div>
          </Poptip>
        </Col>
      </Row>
    </div>
    <!--table-->
    <Row>
      <Table stripe size="small" :columns="tableColums" :data="tableData" ></Table>
    </Row>
    <Row>
      <Page :total="total" :current="currentPage" @on-change="changeCurrentPage" show-total style="float:right;margin-top:10px"></Page>
    </Row>
  </div>

</template>

<script>
  import Cookies from 'js-cookie'
  import {getLogList} from '@/api/system'
  export default {
    name:'log',
    data() {
      return {
        tableColums: [
          {
              type: 'index',
              width: 60,
              title: '序号',
              align: 'center'
          },          
          {
            align:'center',
            title: '用户名',
            key: 'username',
          },
         {
            align:'center',
            title: '具体操作',
            key: 'operation',
          },
          {
            align:'center',
            title: '请求参数',
            key: 'params',
            tooltip:'true'
          },
          {
            align:'center',
            title: '执行时长(毫秒)',
            key: 'time',
          },
          {
              align:'center',
              title: 'IP地址',
              key: 'ip',
          },
          {
              align:'center',
              title: '创建时间',
              key: 'createDate',
          }
        ],
        tableData: [
        ],
        total:0,
        currentPage:1,
        btnLoading:false,
        searchForm:{
          key: '',
          limit:10,
          page:1,
        },
      }
    },
    created(){

    },
    mounted(){
      this.getTableList();
    },
    methods: {
      resetSearch(){
         this.searchForm.loginName='';
          this.searchForm.pg='';
      },
      doSearchTableList(){
        this.getTableList();
      },
      async getTableList(){
        this.searchForm.page = this.currentPage;
        const params = this.searchForm;
        const result = await getLogList(params);
        if (result.code == 0) {
        let res = result.data.list;
        this.total = result.data.totalCount;
        this.tableData = res;
      }
      },
      changeCurrentPage(num){
        this.currentPage=num;
        this.getTableList();
      }
    }
  }

</script>
